<?php

namespace app\admin\model;

use think\Controller;
use think\Model;

class Gift extends Model
{

    public function indexdata($where)
    {
        $list = Self::where('status', 'in', [0, 1])->where('name', 'like', $where)->order('id')->paginate(5, false, ['query'=>request()->param()]);
        return $list;
    }

    public function trashdata($where)
    {
        $list = Self::where('status', 'eq', '2')->where('name', 'like', $where)->order('id')->paginate(5, false, ['query'=>request()->param()]);
        return $list;
    }

    // 插入
    public function savedata($data)
    {
        $this->isUpdate(false)->save($data);
    }

    // 强制更新
    public function updatedata($data)
    {
        $res = $this->isUpdate(true)->save($data);
        return $res;
    }

    // 删除
    public function del($id)
    {
        $res = Self::where('id', 'eq', $id)->delete();
        return $res;
    }
}